package acessoDados.dao.impl;

import java.sql.ResultSet;
import java.sql.SQLException;

import acessoDados.dao.LocalDAO;

public class LocalDAOImpl extends BaseDAOImpl implements LocalDAO{
	public  void criaLocal(int coordX, int coordY, String NomeLocal) throws SQLException, ClassNotFoundException {
		String query = "INSERT INTO local (coordX , coordY, NomeLocal)" + "VALUES (" + coordX + ", " + coordY + ", '" + NomeLocal + "');";
		executaQueryUpdate(query);
	}

	public  ResultSet getLocais() throws SQLException, ClassNotFoundException {
		String query = "SELECT * FROM local";
		return executaQuery(query);
	}

	public  void removeLocal(String idLocal) throws SQLException, ClassNotFoundException {
		String query = "DELETE FROM local WHERE idLocal=" + idLocal + ";";
		executaQueryUpdate(query);
	}

	public  ResultSet getDetalhesLocal(String idLocal) throws SQLException, ClassNotFoundException {
		String query = "SELECT * FROM local WHERE idLocal=" + idLocal + ";";
		return executaQuery(query);
	}

	public void editLocal(int id, int coordX, int coordY, String nome) throws SQLException, ClassNotFoundException {
		String query = "UPDATE local SET NomeLocal='" + nome + "', coordX=" + coordX + ", coordY=" + coordY + " WHERE idLocal=" + id + ";";
		executaQueryUpdate(query);
	}
}
